package ru.spb.osll.myfit.fixtures;

import org.apache.log4j.Logger;

import ru.spb.osll.myfit.fixtures.base.OneLineFixture;
import ru.spb.osll.myfit.ssh.SSHClientManager;
import ru.spb.osll.myfit.ssh.SSHFixturesContainer;
import ru.spb.osll.myfit.ssh.User;

public class ConnectSshToHostFixture extends OneLineFixture {
  private Logger log = Logger.getLogger(ConnectSshToHostFixture.class);
  
  public boolean connectSshToHostWithLoginAndPassword(String ip, String username, String password) throws Exception{
    
    try {
      SSHClientManager mySSHClientManager = new SSHClientManager(ip, new User(username, password));
      SSHFixturesContainer.setSSHClientManager(mySSHClientManager);
    } catch (Exception ex) {
      log.error("Can't connect to host " + ip, ex);
      throw ex;
    }
    return true;
  }
  
  public static String[] getTestTableTemplates() {
    return new String[] {"|connect ssh to host||with login||and password||"};
  }
}
